﻿@using Telerik.Web.Mvc.UI;
@using Telerik.Web.Mvc;
@using Uco.Infrastructure;

@if (ViewData.TemplateInfo.TemplateDepth > 1)
{
    if (Model == null)
    {
        @ViewData.ModelMetadata.NullDisplayText
    }
    else
    {
        @ViewData.ModelMetadata.SimpleDisplayText
    }
}
else
{
    ViewData.Clear();
    <text>
    @(Html.Telerik().TabStrip()
    .Name("TabStrip")
    .Items(tabstrip =>
    {
        foreach (var prop0 in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !ViewData.TemplateInfo.Visited(pm) && pm.Watermark != null).OrderBy(r => r.Order).Select(r => r.Watermark).Distinct())
        {
            string Watermark = prop0;
            if (Watermark == "Hidden") continue;
            tabstrip.Add().Text(Watermark).Content(@<text>
                @foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !ViewData.TemplateInfo.Visited(pm) && pm.Watermark == Watermark).OrderBy(r => r.Order))
                {
                    if (!prop.IsComplexType)
                    {
                        if (prop.HideSurroundingHtml)
                        {
                            @Html.Editor(prop.PropertyName)
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(Html.Label(prop.PropertyName).ToHtmlString()))
                            {
                                <div class="editor-label">@Html.Label(prop.PropertyName) @(prop.IsRequired ? "*" : "")</div>
                            }
                            <div class="editor-field">@Html.Editor(prop.PropertyName) @Html.ValidationMessage(prop.PropertyName)</div>
                        }
                        }
                        else
                        {
                            @Html.Editor(prop.PropertyName)
                        }
                    }
            </text>);
        }
    }).SelectedIndex(0))
    </text>
    
    foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !ViewData.TemplateInfo.Visited(pm) && pm.Watermark == null).OrderBy(r => r.Order))
    {
        if (!prop.IsComplexType)
        {
            if (prop.HideSurroundingHtml)
            {
            @Html.Editor(prop.PropertyName)
            }
            else
            {
                if (!string.IsNullOrEmpty(Html.Label(prop.PropertyName).ToHtmlString()))
                {
                <div class="editor-label">@Html.Label(prop.PropertyName) @(prop.IsRequired ? "*" : "")</div>
                }
            <div class="editor-field">@Html.Editor(prop.PropertyName) @Html.ValidationMessage(prop.PropertyName)</div>
            }
        }
@*        else
        {
            @Html.Editor(prop.PropertyName)
        }*@
    }

}